package com.jxl.apple.components
{
	import com.bit101.components.PushButton;
	
	import flash.display.Bitmap;
	import flash.display.DisplayObjectContainer;
	import flash.filters.BevelFilter;
	import flash.filters.DropShadowFilter;
	import flash.text.Font;
	import flash.text.TextFormat;
	
	public class BackButton extends PushButton
	{
		
		[Embed(source="/assets/images/back-button/up.png")]
		private var BackgroundImagePNG:Class;
		
		private var backgroundImage:Bitmap;
		
		public function BackButton(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0, label:String="", defaultHandler:Function=null)
		{
			super(parent, xpos, ypos, label, defaultHandler);
			
			width = 65;
			height = 32;
		}
		
		protected override function addChildren():void
		{
			super.addChildren();
			
			backgroundImage = new BackgroundImagePNG() as Bitmap;
			addChildAt(backgroundImage, 0);
			
			var tf:TextFormat = _label.textField.defaultTextFormat;
			tf.font = "Helvetica Neue";
			tf.bold = true;
			tf.size = 12;
			tf.color = 0xFFFFFF;
			_label.textField.embedFonts = false;
			_label.textField.defaultTextFormat = tf;
			//_label.filters = [new BevelFilter(1, 90, 0xFFFFFF, .75, 0x000000, .75, 1, 1, 1, 1, "outer", true)];
			//_label.filters = [new DropShadowFilter(1, 45, 0x000000, .01, 1, 1, 1, 1, false, false, false)];
		}
		
		private function fontExists(name:String):Boolean
		{
			name = name.toLowerCase();
			var list:Array = [];
			var fonts:Array = Font.enumerateFonts(true);
			var len:int = fonts.length;
			for(var index:uint = 0; index < len; index++)
			{
				var font:Font = fonts[index];
				if(font.fontName.toLowerCase().indexOf(name) != -1)
				{
					list.push(font);
				}
			}
			return list.length > 0;
		}
		
		public override function draw():void
		{
			super.draw();
			
			_back.graphics.clear();
			_face.graphics.clear();
		}
	}
}